<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	String roleid = request.getParameter("roleid");
	if (roleid == null) {
		roleid = "";
	}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<jsp:include page="../inc/meta.jsp"></jsp:include>
<jsp:include page="../inc/easyui.jsp"></jsp:include>
<script type="text/javascript">
	var cbx_status = null;
	var roleForm = null;
	$(function() {
		roleForm = $('#roleForm').form();

		//角色状态
		cbx_status = $("#status").combobox({
			valueField : 'id',
			textField : 'text',
			editable : false,
			panelHeight : 60,
			data : [ {
				"id" : 0,
				"text" : "正常",
				"selected" : true
			}, {
				"id" : 1,
				"text" : "禁用"
			} ]
		});

		if ($(':input[name="role_id"]').val().length > 0) {
			parent.$.messager.progress({
				text : '数据加载中....'
			});
			$.ajax({
				url : "getrole",
				data : {
					roleid : $(':input[name="role_id"]').val()
				},
				cache : false,
				dataType : "json",
				success : function(data) {
					roleForm.form('load', {
						role_id : data.obj.role_id,
						role_name : data.obj.role_name,
						status : data.obj.status,
						role_desc:data.obj.role_desc
					});
				}
			});

		}
	});

	var saveFun = function($dialog, datagrid,$parent) {
		roleForm.form("submit", {
			url : "addrole",
			data : roleForm.serializeArray(),
			success : function(data) {
				var obj = eval('(' + data + ')');
				if (obj.success) {
					roleForm.form('clear');
					$dialog.dialog('destroy');
				}
				$parent.messager.alert('提示', obj.msg, 'info');
				datagrid.datagrid('reload');
			}
		});
	};

	var editF = function($dialog, datagrid,$parent) {
		roleForm.form('submit', {
			url : "editrole",
			success : function(data) {
				var obj = eval('(' + data + ')');
				if (obj.success) {
					$dialog.dialog('destroy');
				}
				$parent.messager.alert('提示', obj.msg, 'info');
				datagrid.datagrid('reload');
			}
		});
	};
</script>
</head>

<body>
	<form id="roleForm" class="form" method="post">
		<fieldset>
			<legend>角色基本信息</legend>
			<input type="hidden" name="role_id" value="<%=roleid %>" />
			<table class="table" style="width: 100%;">
				<tr>
					<th>角色名称</th>
					<td><input name="role_name" type="text" style="width: 156px;"
						class="easyui-validatebox" required="true" />
					</td>
					<th>状态</th>
					<td><input id="status" name="status" class="easyui-combobox"
						type="text" style="width: 156px;" />
					</td>
				</tr>
				<tr>
					<th>角色描述</th>
					<td><input name="role_desc" type="text" style="width: 156px;"
						class="easyui-validatebox"/>
					</td>
				</tr>
			</table>
		</fieldset>
	</form>
</body>
</html>
